home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / RGASM.RAR / ASMCODE.EXE / CHAPT7 / CLIPDEMO.PRG next >
Encoding:
Text File  |  1993-05-10  |  4.7 KB  |  190 lines

  1. *
  2. *  Program ClipDemo ( Chapter 7 )
  3. *
  4. Save screen
  5. NormColor   = "W/B"
  6. BrightColor = "W+/B"
  7. BlinkColor  = "W+/R+"
  8. TitleColor  = "GR+/B"
  9. MsgColor    = "W+/G+"
  10. Set color to &NormColor
  11. Clear
  12. DemoLine = 1
  13. StepRow  = 1
  14. DummyVar = "                                                                 "
  15. WhoTurned = "You have turned "
  16. OutLine = DemoLine + StepRow
  17. Do OutText with "The Clipper Demo Program - controlling the keyboard",TitleColor
  18. Do OutText with "═══════════════════════════════════════════════════"  , TitleColor
  19. StepRow = 2
  20. Do OutText with "Version 1.1    06.05.92   Voronezh, Russia" , TitleColor
  21. Set color to &NormColor
  22. DemoLine = Row()
  23. OutLine = DemoLine + StepRow
  24. If IsKbdEnh()
  25.    KbdType = "an enhanced"
  26. Else
  27.    KbdType = "a standard"
  28. EndIf
  29. OutStr = "Determining the keyboard type"
  30. Do OutText with OutStr , BrightColor
  31. OutStr = "  You have " + KbdType + " keyboard.  "
  32. Do OutText with Outstr , MsgColor
  33. @ 23 , 1 Say " "
  34. Set color to &BlinkColor
  35. Wait
  36.  
  37. Set color to &NormColor
  38. @ DemoLine , 0 Clear to 24,79
  39. OutLine = DemoLine + StepRow
  40. Do OutText with "Getting the NumLock state" , BrightColor
  41. If GNumLock()
  42.    OutStr = "ON"
  43. Else
  44.    OutStr = "OFF"
  45. EndIf
  46. Do OutText with "The NumLock state is now " + OutStr , NormColor
  47. Do OutText with "Press the NumLock key" , NormColor
  48. Do WaitNL
  49. Do TestNL
  50. @ 23 , 1 Say " "
  51. Set color to &BlinkColor
  52. Wait
  53.  
  54. Set color to &NormColor
  55. @ DemoLine + StepRow * 2 , 0 Clear to 24,79
  56. OutLine = DemoLine + StepRow * 2
  57. Do OutText with "Press the NumLock key again" , BrightColor
  58. Do WaitNL
  59. Do TestNL
  60. @ 23 , 1 Say " "
  61. Set color to &BlinkColor
  62. Wait
  63.  
  64. Set color to &NormColor
  65. @ DemoLine , 0 Clear to 24,79
  66. OutLine = DemoLine + StepRow
  67. Do OutText with "Getting the CapsLock state" , BrightColor
  68. If GCapsLock()
  69.    OutStr = "ON"
  70. Else
  71.    OutStr = "OFF"
  72. EndIf
  73. Do OutText with "The CapsLock state is now " + OutStr , NormColor
  74. Do OutText with "Press the CapsLock key" , NormColor
  75. Do WaitCL
  76. Do TestCL
  77. @ 23 , 1 Say " "
  78. Set color to &BlinkColor
  79. Wait
  80.  
  81. Set color to &NormColor
  82. @ DemoLine + StepRow * 2 , 0 Clear to 24,79
  83. OutLine = DemoLine + StepRow * 2
  84. Do OutText with "Press the CapsLock key again" , BrightColor
  85. Do WaitCL
  86. Do TestCL
  87. @ 23 , 1 Say " "
  88. Set color to &BlinkColor
  89. Wait
  90.  
  91. WhoTurned = "Program is turning "
  92. Set color to &NormColor
  93. @DemoLine , 0 Clear to 24,79
  94. OutLine = DemoLine + StepRow
  95. Do OutText with "Changing the NumLock state from within the program" , BrightColor
  96. Do OutText with "The NumLock state is turned ON" , NormColor
  97. SnumLock (1)
  98. Do TestNl
  99. @ 23 , 1 Say " "
  100. Set color to &BlinkColor
  101. Wait
  102. Set color to &NormColor
  103. OutLine = DemoLine + StepRow * 2
  104. @OutLine , 0 Clear to 24,79
  105. Do OutText with "The NumLock state is turned OFF" , NormColor
  106. SnumLock (0)
  107. @ 23 , 1 Say " "
  108. Set color to &BlinkColor
  109. Wait
  110.  
  111.  
  112. Set color to &NormColor
  113. @DemoLine , 0 Clear to 24,79
  114. OutLine = DemoLine + StepRow
  115. Do OutText with "Changing the CapsLock state from within the program" , BrightColor
  116. Do OutText with "The CapsLock state is turned ON" , NormColor
  117. SCapsLock (1)
  118. Do TestCL
  119. @ 23 , 1 Say " "
  120. Set color to &BlinkColor
  121. Wait
  122. Set color to &NormColor
  123. OutLine = DemoLine + StepRow * 2
  124. @OutLine , 0 Clear to 24,79
  125. Do OutText with "The CapsLock state is turned OFF" , NormColor
  126. SCapsLock (0)
  127. Do TestCL
  128. @ 23 , 1 Say " "
  129. Set color to &BlinkColor
  130. Wait
  131. Set color to &Normcolor
  132. Clear
  133. Restore screen
  134.  
  135.  
  136. Procedure OutText
  137. Parameters TextStr , TextColor
  138. Set color to &TextColor
  139. ColumnNum = ( 80 - Len(TextStr)) / 2
  140. @ OutLine , ColumnNum Say TextStr
  141. OutLine = OutLine + StepRow
  142. Set color to &NormColor
  143. Return
  144.  
  145. Procedure WaitNL
  146. NLStateO = GNumLock()
  147. NLStateN = NLStateO
  148. Do While NlStateO = NLStateN
  149.    NLStateN = GNumLock()
  150. EndDo
  151. Return
  152.  
  153. Procedure TestNL
  154. Clear Gets
  155. If GNumLock()
  156.    Do OutText with WhoTurned + " the NumLock ON" , NormColor
  157.    Do OutText with "Now you can use the numeric pad" , NormColor
  158.    OutStr = "Press few keys on numeric pad finishing with the ENTER key"
  159.    Do OutText with OutStr , NormColor
  160.    @ Row() + 2 , 7 Get DummyVar
  161.    Read
  162. Else
  163.    Do OutText with WhoTurned + " the NumLock OFF" , NormColor
  164. EndIf
  165. DummyVar = "                                                                 "
  166. Return
  167.  
  168. Procedure WaitCL
  169. CLStateO = GCapsLock()
  170. CLStateN = CLStateO
  171. Do While CLStateO = CLStateN
  172.    CLStateN = GCapsLock()
  173. EndDo
  174. Return
  175.  
  176. Procedure TestCL
  177. Clear Gets
  178. If GCapsLock()
  179.    OutStr = "ON"
  180. Else
  181.    OutStr = "OFF"
  182. EndIf
  183. Do OutText with WhoTurned + " the CapsLock " + OutStr , NormColor
  184. OutStr = "Press few character keys finishing with the ENTER key"
  185. Do OutText with OutStr , NormColor
  186. @ Row() + 2 , 7 Get DummyVar
  187. Read
  188. DummyVar = "                                                                 "
  189. Return
  190.